package com.hlhj.funlike_business.activity.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hlhj.funlike_business.R;
import com.hlhj.funlike_business.bean.FoodTypeBean;

import java.util.List;

public class FoodTypeAdp extends BaseQuickAdapter<FoodTypeBean.DataBean,BaseViewHolder> {
    public FoodTypeAdp(@Nullable List<FoodTypeBean.DataBean> data) {
        super(R.layout.adp_preferential,data);
    }

    @Override
    protected void convert(final BaseViewHolder helper, final FoodTypeBean.DataBean item) {
        TextView textview = helper.getView(R.id.tv_foodtype);
        TextView manjian = helper.getView(R.id.tv_adp_manjian);
        ImageView del = helper.getView(R.id.img_del);

        textview.setVisibility(View.VISIBLE);
        manjian.setVisibility(View.GONE);
        textview.setText(item.getType_name());
        del.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener!=null){
                    listener.showDel(item.getId());
                }
//                remove(helper.getAdapterPosition());
//                notifyDataSetChanged();
            }
        });
    }

    public interface getResult{
        void showDel(int id);
    }

    public getResult listener;

    public void setListener(getResult listener) {
        this.listener = listener;
    }
}
